#include "mainscene.h"
#include "ui_mainscene.h"
#include "CMainWindow.h"
#include "mainscene.h"
#include"qaction.h"
#include"qpainter.h"
#include"mypushbutton.h"

MainScene::MainScene(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainScene)
{
    ui->setupUi(this);

    //配置主场景

    setFixedSize(600,600);
    //设置标题
    setWindowTitle("HuaRongPass");

//    //退出按钮实现
//    connect(ui->actionquit,&QAction::triggered,[=](){
//        this->close();
//    });


    //开始按钮
    MyPushButton* startBtn=new MyPushButton(":/res/begin.png");
    startBtn->setParent(this);
    startBtn->move(this->width()*0.5 - startBtn->width()*0.5,this->height()*0.7);

    //实例化主窗口
    cmainwindow=new CMainWindow;

    //监听事件
    connect(startBtn,&MyPushButton::clicked,[=](){
        qDebug()<<"点击了开始";

        //做弹跳特效
        startBtn->zoom1();
        startBtn->zoom2();

        //进入游戏主界面
        //自身隐藏
        this->hide();
        //显示主界面
        cmainwindow->initial();
        cmainwindow->show();


    });

}

void MainScene::paintEvent(QPaintEvent* QPaintEvent){

    QPainter painter(this);
    QPixmap pix;
    pix.load(":/res/background.jpg");
    painter.drawPixmap(0,0,this->width(),this->height(),pix);
}
MainScene::~MainScene()
{
    delete ui;
}

     
